<?php
/**************************************************************************
 * Naanal PHP Framework, Simple, Efficient and Developer Friendly
 * Ver 3.0, Copyright (C) <2010>  <Tamil Amuthan. R>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ************************************************************************/
class ClsNaanalmodwrap
{
    private $objConfig=null;
    private $module="";
    public function __construct($module,$objConfig) {
        $this->objConfig=$objConfig;
        $this->module=$module;
    }
    public function render()
    {
        $arrMethod=array();
        
        $arrFieldMethod=$this->objConfig->getTableFieldMethods();
        foreach($arrFieldMethod as $arrMeth)
        {
            $getter=isset($arrMeth["getter"])?$arrMeth["getter"]:"";
            $setter=isset($arrMeth["setter"])?$arrMeth["setter"]:"";
            if(!empty($getter))
            {
            $arrMethod[]="
    public function get_{$getter}()
    {
        return \$this->{$getter};
    }";
            }
            if(!empty($setter))
            {
            $arrMethod[]="
    public function get_{$setter}()
    {
        return \$this->{$setter};
    }";
            }
        }
        
        $methods=implode("",$arrMethod);
        $class="ClsW".ucfirst($this->module);
        $wrapper='<?php
'."class {$class} extends ClsWrapper
{
    public function __construct()
    {
        parent::__construct();
    }
    {$methods}
}".'
?>';
        return $wrapper;
    }
}
?>